﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DeviceManager.DataAccessLayer;
using DeviceManager.BusinessLogicLayer;
using Presentation;

namespace DeviceManagementIT.Formain.LoginSoftware
{
    public partial class frmLoginAccount : DevExpress.XtraEditors.XtraForm
    {
        UserBllOperation unitbll = new UserBllOperation();
        public frmLoginAccount()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Length == 0) { lblTextUser.Text = "Mã nhân viên không để trống!"; return;};
            if (txtUser.Text.Length > 0 && txtPass.Text.Length == 0) { lblTextPass.Text = "Mật khẩu nhân viên không để trống!"; return; };
            if (!unitbll.CheckUser(new NGUOIDUNG(), txtUser.Text)) { lblTextUser.Text = "Sai tài khoản!";return;};
            if (unitbll.CheckUser(new NGUOIDUNG(), txtUser.Text) && !unitbll.CheckPass(new NGUOIDUNG(), txtPass.Text)) { lblTextPass.Text = "Sai mật khẩu!"; return; };
            DeviceManagement frm_DeviceManagement = new DeviceManagement();
            frm_DeviceManagement.Show();this.Hide();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}